import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const home = {
  path: '/home',
  component: () => import('@/views/home'),
  meta: {
    title: 'home'
  }
}

const login = {
  path: '/login',
  component: () => import('@/views/login'),
  meta: {
    title: 'login'
  }
}

const power = {
  path: '/power',
  component: () => import('@/views/power'),
  meta: {
    title: 'power'
  }
}

const staticRoutes = [home, login]

export const asyncRroutes = [power]

const createRouter = () => new VueRouter({
  routes: [...staticRoutes]
})

const router = createRouter()

export function resetRouter () {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
